
if (SERVER) then

	AddCSLuaFile( "shared.lua" )
	SWEP.Weight				= 5
	SWEP.AutoSwitchTo		= false
	SWEP.AutoSwitchFrom		= false
	SWEP.HoldType			= "shotgun"

end

if ( CLIENT ) then
	
	SWEP.ViewModelFOV		= 62
	
	SWEP.IconFont = "CSSelectIcons"
	
	SWEP.PrintName = "Defender Shotgun"
	SWEP.Slot = 0
	SWEP.Slotpos = 0
	SWEP.IconLetter = "k"
	
	killicon.AddFont( "weapon_defendershotgun", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )

end

/*---------------------------------------------------------
   PRIMARY
   Semi Auto
---------------------------------------------------------*/

 SWEP.Base				= "pf_base"

 SWEP.Spawnable = true;
 SWEP.AdminSpawnable = true;

 SWEP.ViewModel			= "models/weapons/v_shotgun.mdl"
 SWEP.WorldModel			= "models/weapons/w_shotgun.mdl"

 SWEP.Primary.Sound			= Sound( "weapons/shotgun/shotgun_fire6.wav" )
 SWEP.Primary.Recoil			= 2.1
 SWEP.Primary.Damage			= 6
 SWEP.Primary.VehDamageScale    = .6
 SWEP.Primary.NumShots		      = 24
 SWEP.Primary.Cone			= 0.125
 SWEP.Primary.ClipSize              = 6
 SWEP.Primary.Delay			= 0.55
 SWEP.Primary.DefaultClip           = 99999
 SWEP.Primary.Automatic             = false
 SWEP.Primary.Ammo                  = "buckshot"

 SWEP.Secondary.Clipsize            = -1;
 SWEP.Secondary.DefaultClip         = -1;
 SWEP.Secondary.Automatic           = false
 SWEP.Secondary.Ammo                = "none"; 
 SWEP.Secondary.Delay				= 0
 
 SWEP.DoPump = 90000

function SWEP:PrimaryAttack()

	if ( self.Weapon:Clip1() <= 0 ) then 
		self.Weapon:EmitSound(Sound("weapons/shotgun/shotgun_empty.wav"),100,math.random(90,110)) 
	return end
	
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	if ( !self:CanPrimaryAttack() ) then return end
	
	self:ShootBullet( self.Primary.NumShots, self.Primary.Damage, self.Primary.Sound, self.Primary.Cone, self.Primary.Recoil )
	//self:TakePrimaryAmmo(1)
	self.DoPump = CurTime() + .19
	self.Pumped = false
	//:PumpIt()
end

function SWEP:Deploy()
	self.Weapon:SetNetworkedBool( "reloading", false )
	self.DoPump = 90000
end

function SWEP:Reload()
	if ( self.Weapon:GetNetworkedBool( "reloading", true ) ) then return end

	if ( self.Weapon:Clip1() <= self.Primary.ClipSize ) then
		
		self.Weapon:SetNetworkedBool( "reloading", true )
		self.Weapon:SetVar( "reloadtimer", CurTime() + 0.35 )
		self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
		
	end

return true end

function SWEP:Think()
	if self.DoPump < CurTime() and not self.Pumped then
		self:PumpIt()
		self.Pumped = true
	end
	if ( self.Weapon:GetNetworkedBool( "reloading", false ) ) then
		if ( self.Weapon:GetVar( "reloadtimer", 0 ) < CurTime() ) then
			
			// Finsished reload
			local size = self.Primary.ClipSize
			local clip1 = self.Weapon:Clip1() or 0
			if ( clip1 == size ) then
				self.Weapon:SetNetworkedBool( "reloading", false )
				return
			end
			
			// Next cycle
			self.Weapon:SetVar( "reloadtimer", CurTime() + 0.4 )
			self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
			
			// Add ammo
			local clip = self.Weapon:Clip1()
			self.Weapon:SetClip1(  clip + 1 )
			
			// Sounds
			self.Weapon:EmitSound( Sound("weapons/shotgun/shotgun_reload3.wav"),100,math.random(90,110) )
			
			// Finish filling, final pump
			if ( self.Weapon:Clip1() >= self.Primary.ClipSize ) then
				self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
				//self.Weapon:GetOwner():ChatPrint("done reloading.")
			else
			end
		end
	end
end

function SWEP:PumpIt()
	self.Weapon:SetNetworkedBool( "reloading", false )
	self.Weapon:SendWeaponAnim( ACT_SHOTGUN_PUMP )
	self.Weapon:EmitSound( "Weapon_Shotgun.Special1" )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

function SWEP:SecondaryAttack()
	return
end




